//
//  ViewController.m
//  SQLiteForOCModel
//
//  Created by 唐健 on 2018/10/3.
//  Copyright © 2018年 唐健. All rights reserved.
//

#import "ViewController.h"
#import "TestModel_One.h"
#import "NSObject+SQModel_id.h"

@interface ViewController ()

@property (weak, nonatomic) IBOutlet UIImageView *testImageView;
@property (nonatomic,strong) TestModel_One *model;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    if(self.model == nil){
        [self testActionSetModel];
    }
    [self testModelDealModel];
}

- (void)testActionSetModel{
    
    
    for(int i = 0 ; i < 8;i++){
        self.model.modelOneSign = [NSString stringWithFormat:@"modelOneSign_%d",i];
      
    
    TestModel_One *testModel = [TestModel_One new];
    testModel.modelOneSign = [NSString stringWithFormat:@"modelMainKey_ %d",i];
    testModel.intergerNum = 8+i ;
    testModel.floatNum = 9.89+i;
    testModel.boolValue = YES;
//    testModel.TestModelSuperClassSign = @"TestModelSuperClassSign";
    testModel.dict_rootModel = @{@"dict_rootModelKey":@"dict_rootModelValue"};
//    NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"IMG_2420.JPG" ofType:nil]];
//    UIImage *image = [UIImage imageNamed:@"IMG_2420"];
//    UIImage *image = [UIImage imageWithData:data];
//    testModel.rootImage = image;
//    testModel.rootData = data;
    testModel.oneLeveModel = [TestModel_lv01 new];
    testModel.oneLeveModel.oneLeveSign = @"lv01";
    
    
    testModel.oneLeveModel.twoLeveModel02 = [TestModel_lv02 new];
    testModel.oneLeveModel.twoLeveModel02.twoLeveSign = @"lv02";
        
        [testModel sq_save:^(BOOL isSuccess) {
            NSLog(@"sq_save ->%d",isSuccess);
        }];
        self.model = testModel;
    }
        
        
  
}


- (void)testModelDealModel{
    
   
//
    
//    [[self.model class] sq_selectForSQModel_id:@"modelOneSign_1" selectResult:^(id obj) {
//
//    }];
    
//    [[self.model class] sq_selectAllSQModelSelectResult:^(NSArray *objs) {
//        for(TestModel_One *model in objs){
//            [TestModel_One  sq_deleteForSQModel_id:model.SQModel_id deleteResult:^(BOOL isSuccess) {
//
//            }];
//        }
//    }];

//    [[self.model class] sq_deleteAllSQModelDeleteResult:^(BOOL isSuccess) {
//        
//    }];
    
//    [self.model sq_save:^(BOOL isSuccess) {
//
//    }];
//    NSLog(@"keyValues ->%@",keyValues);
//
//
//    TestModel_One *dealModel = [TestModel_One mj_objectWithKeyValues:keyValues];
//    self.testImageView.image = [UIImage imageWithData:dealModel.rootData];
//    [TestModel_One sq_deleteAllSQModelDeleteResult:^(BOOL isSuccess) {
//
//    }];
    
}



@end
